import Cache from './cache'
export default {
    filter2date(val) {
        let temp = '';
        try {
            if (val) temp = new Date(val).Format();
        } catch (e) {}
        return temp;
    },
    /**
     * 日期转换
     * isM:true  年月日
     * isS:true 年月日 时分秒
     * 默认：年月日 时分
     */
     filter2time: function (data, isM, isS, isData) {
        var d = new Date(data)
        var y = d.getFullYear();
        var m = d.getMonth() + 1 < 10 ? "0" + (d.getMonth() + 1) : d.getMonth() + 1;
        var D = d.getDate() < 10 ? "0" + d.getDate() : d.getDate();
        var h = d.getHours() < 10 ? "0" + d.getHours() : d.getHours();
        var M = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
        var s = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds();
        if (isS === true) {
            return y + "-" + m + "-" + D + " " + h + ":" + M + ":" + s
        } else if (isM === true) {
            return y + "-" + m + "-" + D;
        } else if (isData === true) {
            console.log(data)
            return y + "年" + m + "月" + D + "日  " + h + ":" + M
        } else {
            return y + "-" + m + "-" + D + " " + h + ":" + M
        }
    },
}